package cn.fl.continfo.controller;

import cmm.web.core.framework.controller.BaseController;
import cn.cmm.base.framework.utils.BaseLogUtils;
import cn.fl.commons.result.ResponseData;
import cn.fl.continfo.vo.PrjContCfgVO;
import cn.fl.framework.base.context.CurrentThreadContext;
import cn.fl.preloan.IPrjContCfgApiService;
import cn.fl.preloan.condition.PrjContCfgQueryCondition;
import cn.fl.preloan.dto.PrjContCfgDTO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

/**
 * @Description: 机构合同方案 控制层
 */
@RestController
@RequestMapping(value = "/ins/cont")
public class InsContController extends BaseController {

    @Autowired
    IPrjContCfgApiService contCfgApiService;

    /**
     * 到列表页面
     */
    @RequestMapping(value = "/toContConfigListPage.do", method = { RequestMethod.GET, RequestMethod.POST})
    public ModelAndView toListPage(HttpServletRequest request) {
        BaseLogUtils.newLogger("合同配置加载列表页面.请求参数：" + this.getRequestParameter(request), CurrentThreadContext.getCurrentUserName()).info();
        ModelAndView view = new ModelAndView("continfo/inscont/insContPrjList");
        String insCode = request.getParameter("insCode");
        PrjContCfgQueryCondition queryCondition = new PrjContCfgQueryCondition();
        queryCondition.setInsCode(insCode);
        ResponseData<List> responseData = contCfgApiService.selectList(queryCondition);
        if (responseData.isSuccess()) {
            List<PrjContCfgDTO> list = responseData.getData();
//            PrjContCfgVO prjContCfgVO = new PrjContCfgVO();
//            BeanUtils.copyProperties(prjContCfgDTO, prjContCfgVO);
            view.addObject("list", list);
        }
        view.addObject("insCode", insCode);
        return view;
    }
}
